package com.xuhai.blog.admin.controller;


import com.xuhai.blog.admin.entity.CommentEntity;
import com.xuhai.blog.admin.service.CommentService;
import com.xuhai.blog.common.util.ResultJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 评论表 前端控制器
 * </p>
 *
 * @author 机蜂
 * @since 2022-02-08
 */
@RestController
@RequestMapping("/admin/comment")
public class CommentController {

    @Autowired
    private CommentService commentService;

    @GetMapping("/page")
    public ResultJson page(int page, int limit, CommentEntity comment){
        return ResultJson.ok().data(commentService.getPage(page, limit, comment));
    }

    @PostMapping(value = {"/exam","/status"})
    public ResultJson exam(@RequestBody CommentEntity comment){
        commentService.updateById(comment);
        return ResultJson.ok();
    }

    @GetMapping("/info/{commentId}")
    public ResultJson info(@PathVariable Integer commentId){
        return ResultJson.ok().data(commentService.getById(commentId));
    }

    @DeleteMapping("/delete/{commentId}")
    public ResultJson delete(@PathVariable Integer commentId){
        commentService.removeById(commentId);
        return ResultJson.ok();
    }


}

